# utils/assertion_utils.py
import re
import json
import time
import datetime
from typing import Dict, Any, List


class AssertionUtils:
    @staticmethod
    def assert_status_code(response, expected_code: int):
        """断言HTTP状态码"""
        assert response.status_code == expected_code, \
            f"状态码断言失败: 期望 {expected_code}, 实际 {response.status_code}"

    @staticmethod
    def assert_response_fields(response_json: Dict, expected_fields: List[Dict]):
        """断言响应字段"""
        for field in expected_fields:
            for key, expected_value in field.items():
                assert key in response_json, f"响应缺少字段: {key}"
                assert response_json[key] == expected_value, \
                    f"字段 {key} 值不匹配: 期望 {expected_value}, 实际 {response_json[key]}"